<template>
  <div class="top-title">
    <div v-if="updateTime" class="title_lt updateTime">
      <span class="currentPage">{{ content[0][0] }}</span>
      <span class="getTime">/数据更新时间：{{ this.$moment().format('YYYY/MM/DD HH:mm:ss') }}</span>
    </div>
    <div v-else-if="policeView" class="title_lt updateTime">
      <span class="currentPage">{{ cusString }}</span>
      <span class="getTime">/数据更新时间：{{ this.$moment().format('YYYY/MM/DD HH:mm:ss') }}</span>
    </div>
    <!-- <div v-else class="title_lt">
      <span v-for="(v, i) in content[0]" :key="i" class="currentPage" @click="goBack(v)">{{ v }}</span>
      <span class="nextPage" style="color: var(--theme-search-label-text-color)">-{{ content[1][0] }}</span>
      <span class="getTime">/数据更新时间：{{ this.$moment().format('YYYY/MM/DD HH:mm:ss') }}</span>
    </div> -->
    <div v-else class="title_lt">
      <span v-for="(v, i) in content[0]" :key="i" @click="goBack(v)" class="currentPage" :style="{ color: titleColor }"
        >{{ v }}
      </span>
      <span class="nextPage" v-if="content[1][0]">-{{ content[1][0] }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'topTitle',
  props: {
    //显示时间或者标题栏
    updateTime: {
      type: Boolean,
      default: false,
    },
    //内容
    content: {
      type: Array,
      default: () => [],
    },

    policeView: {
      type: Boolean,
      default: false,
    },
    cusString: {
      default: '',
    },
    titleColor: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      title: '',
    }
  },
  methods: {
    goBack(v) {
      var arr = [...this.content[0]]
      arr.reverse()
      for (let i = 0; i < arr.length; i++) {
        if (arr[i] == v) {
          this.$router.go(-1)
        }
      }
    },
  },
}
</script>

<style lang="less">
//每页标题
.top-title {
  height: 0.5rem;
  color: var(--theme-search-label-text-color);
  // background: #fff;
  display: flex;
  align-items: center;
  font-family: PingFang SC;
  padding-left: 0.2rem;
  flex-shrink: 0;

  .title_lt {
    padding-left: 0.1rem;
    border-left: 0.04rem solid var(--theme-search-label-text-color);

    .currentPage {
      color: var(--theme-search-label-text-color);
      font-size: 0.16rem;
      font-weight: bold;
      margin-right: 0.02rem;
      cursor: pointer;
    }

    .getTime {
      font-size: 0.14rem;
      font-weight: 400;
      color: var(--theme-search-label-text-color);
      cursor: pointer;
    }

    .nextPage {
      font-size: 0.16rem;
      font-weight: bold;
      cursor: pointer;
    }
  }

  .updateTime {
    .currentPage {
      font-size: 0.16rem;
      font-family: PingFang SC;
      font-weight: bold;
      margin-right: 0.05rem;
    }
  }
}
</style>
